-
Notifications
You must be signed in to change notification settings - Fork 1
Avoid trouble with shutting down HTTPClient #45
Conversation
f4803f7
to
9988a3a
Compare
9988a3a
to
c20ae2a
Compare
@@ -6,21 +6,36 @@ import NIO | |||
import NIOHTTP1 | |||
|
|||
struct InstrumentedHTTPClient { | |||
private let client = HTTPClient(eventLoopGroupProvider: .createNew) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we were ignoring the init's passed in value here; so fixed this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, how did I miss that? 🤦♂️😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
happens :)
@@ -9,15 +9,15 @@ import NIOHTTP1 | |||
import NIO | |||
|
|||
let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount) | |||
let threadPool = NIOThreadPool(numberOfThreads: 6) | |||
threadPool.start() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think we'll need one?
@@ -57,8 +56,9 @@ httpClient.get(url: "http://localhost:8080").whenComplete { result in | |||
sleep(20) | |||
|
|||
try httpClient.syncShutdown() | |||
try orderServiceChannel.close().wait() | |||
try storageServiceChannel.close().wait() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we don't really have to right now since we kill the EL, but this would be a good way if we had any cleanup to do in channelRemoved
-- but we don't... So consider this optional here I guess
@@ -6,21 +6,36 @@ import NIO | |||
import NIOHTTP1 | |||
|
|||
struct InstrumentedHTTPClient { | |||
private let client = HTTPClient(eventLoopGroupProvider: .createNew) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, how did I miss that? 🤦♂️😁
|
||
let orderServiceBootstrap = ServerBootstrap(group: eventLoopGroup) | ||
.serverChannelOption(ChannelOptions.backlog, value: 256) | ||
.serverChannelOption(ChannelOptions.socketOption(.so_reuseaddr), value: 1) | ||
.childChannelInitializer { channel in | ||
channel.pipeline.configureHTTPServerPipeline().flatMap { | ||
channel.pipeline.addHandler(OrderServiceHandler(instrument: FakeTracer())) | ||
channel.pipeline.addHandler(OrderServiceHandler(httpClient: httpClient, instrument: FakeTracer())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
No description provided.